import pytest
from app import create_app
from database import db as _db


@pytest.fixture(scope="module")
def app():
    _app = create_app(db_uri="sqlite://", echo=False, testing=True)

    with _app.app_context():
        _db.create_all()

        yield _app

        _db.session.close()
        _db.drop_all()


@pytest.fixture
def client(app):
    client = app.test_client()
    yield client


@pytest.fixture
def db(app):
    with app.app_context():
        yield _db
